package com.mydesign.demo.job;

import com.mydesign.demo.bean.StoreToAssignment;
import com.mydesign.demo.bean.StoreToAssignmentExample;
import com.mydesign.demo.mapper.StoreToAssignmentMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class scanAssignment {
    private Logger logger = LoggerFactory.getLogger(getClass());
    @Autowired
    StoreToAssignmentMapper assignmentMapper;
    @Scheduled(cron = "*/15 * * * * ?")
    public void execute() {
        logger.info("开始扫描拒绝的订单");
        StoreToAssignmentExample storeToAssignmentExample=new StoreToAssignmentExample();
        storeToAssignmentExample.createCriteria().andStatusEqualTo(2);//获取全部取消得订单
        List<StoreToAssignment> storeToAssignments = assignmentMapper.selectByExample(storeToAssignmentExample);
        for (StoreToAssignment e:storeToAssignments){
            e.setStatus(6);//更改为状态6展示在广场，被商家接单后修改为1
            e.setStoreId(null);
            assignmentMapper.updateByPrimaryKey(e);
        }
    }
}
